package com.study.customer.service;

import com.study.customer.dao.GameGoodsDao;
import com.study.customer.pojo.GameGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GameGoodsService {
    @Autowired
    private GameGoodsDao gameGoodsDao;

    /**
     * 上架游戏
     *
     * @param gameGoods
     * @return
     */
    @CacheEvict(value = "customerGoodsCache",allEntries = true)
    public GameGoods addGoods(GameGoods gameGoods) {
        return gameGoodsDao.save(gameGoods);
    }

    /**
     * 查询所有游戏
     *
     * @return
     */
    public List<GameGoods> findAll() {
        return gameGoodsDao.findAll();
    }


    /**
     * 根据id删除游戏
     * @param id
     */
    @CacheEvict(value = "customerGoodsCache",allEntries = true)
    public void deleteById(Long id) {
        gameGoodsDao.deleteById(id);
    }
}
